<?php

declare(strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 */
class UserCourseTaskProgress extends Model
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'user_course_task_progress';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = [
        'status',
        'start_at',
        'end_at',
        'course_task_id',
        'user_id'
    ];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = [];

    public function endCourseTaskOnTaskId()
    {
        return $this->update([
            'status' => 2,
            'end_at' => date('Y-m-d H:i:s')
        ]);
    }
}
